<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>{$setting.site_name}</title>
    <link type="text/css" rel="stylesheet" href="__MOBILE__/css/mobile/bootstrap.min.css">
    <link type="text/css" rel="stylesheet" href="__MOBILE__/css/mobile/font-awesome.min.css">
    <link type="text/css" rel="stylesheet" href="__MOBILE__/js/mobile/need/layer.css">
    <link type="text/css" rel="stylesheet" href="__MOBILE__/css/mobile/main.css">
    <script type="text/javascript" src="__MOBILE__/js/jquery1.js"></script>
    <!-- <script type="text/javascript" src="js/mobile/form.min.js"></script> -->
    <script type="text/javascript" src="__MOBILE__/js/mobile/layer.js"></script>
    <script type="text/javascript" src="__MOBILE__/js/mobile/base.js"></script>
</head>
<body>
<div class="container-fluid reg">
    <div class="head">
        <a class="f_l" href="javascript:history.back();" style="width: 30px;font-size: 30px"><i class="icon-angle-left"></i></a>
        <a>忘记密码</a>
        <a class="f_r" href="/" style="width: 40px;font-size: 25px"><i class="icon-home"></i></a>
    </div>
    <div class="con" id="forget">
        <form>
            <ul>
                <li><input id="zcname" name="zcname" type="text" placeholder="用户名(4-10位字符)" minlength="4" maxlength="10" class="form-control input-lg"></li>
                <li><input id="zctel" name="zctel" type="text" placeholder="手机号码" maxlength="11" class="form-control input-lg"></li>
                <!-- <li style="position:relative;"><input id="zcvcode" name="zcvcode" type="text" placeholder="验证码" class="form-control input-lg"><a href="javascript:;" style="position:absolute; top:50%; right:8px; margin-top:-15px;"><img src="images/mobile/vcode.png" style="width:80px; height:30px;" alt="none" title="看不清？点击更换一张验证图片"></a></li> -->
                <li><input name="regBtn" type="button" class="btn btn-primary btn-lg" value="下一步" onclick="usercheck();"></li>
            </ul>
        </form>
    </div>
    <div class="con" id="forget2" style="display:none;">
        <form>
            <ul>
                <li style="position:relative;"><input id="zcvcode" name="zcvcode" type="text" placeholder="手机验证码" class="form-control input-lg"><input type="button" id="getRegYzm" class="btn-vcode" value="重新获取" onclick="getVcode('10')"></li>
                <li><input id="passwd" name="passwd" type="password" placeholder="密码(6-20位字符)" minlength="6" maxlength="20" class="form-control input-lg"></li>
                <li><input id="passwdse" name="passwdse" type="password" placeholder="再次输入密码" minlength="6" maxlength="20" class="form-control input-lg"></li>
                <li><input name="regBtn" type="button" class="btn btn-primary btn-lg" value="确定" onclick="setpwd();"></li>
            </ul>
        </form>
    </div>
</div>
<div class="footer abs">
    <ul>
        <li><span>手机版</span> | <a href="http://www.jzz555.com" target="_blank">电脑版</a></li>
        <li>易记域名：www.jzz555.com </li>
        <li>© 2017 {$setting.site_name} 版权所有</li>
    </ul>
</div>
<script type="text/javascript">
    function usercheck() {
        var name = $("#zcname");
        if(name.val() == "") {
            var e = function() {
                name.focus();
            };
            lay_msg('请输入用户名！', e);
            return false;
        }
    var n_reg = /^[a-zA-Z0-9_]{4,10}$/;
    if(!n_reg.test(name.val())) {
      var e = function() {
                name.focus();
            };
            lay_msg('用户名只能为4-10位的字母数字下划线组合！', e);
            return false;
    }


        var tel=$("#zctel");
        if(tel.val() == "") {
            var e = function() {
                tel.focus();
            };
            lay_msg('请输入手机号码！', e);
            return false;
        }
        var t_reg=/^[1][3-8]\d{9}$/;
        if(!t_reg.test(tel.val())) {
            var e = function() {
                tel.focus();
            };
            lay_msg('请输入正确的手机号码！', e);
            return false;
        }

/*         var vcode = $("#zcvcode");
        if(vcode.val() == "") {
            var e = function() {
                vcode.focus();
            };
            lay_msg('请输入验证码！', e);
            return false;
        } */
        $.post('forget_password', {
            username: name.val(),
            mobile: tel.val()
        }, function(d) {
            if (d.success) {
            	lay_msg(d.message);
            	$("#forget").hide();
            	$("#forget2").show();
    			$(".step1").removeClass("on");
    			$(".step2").addClass("on");
            } else {
            	lay_msg(d.message);
            }
        },'json')
    }
    
    function getVcode(t){ 
    	var t = 60;
        var getRegYzm = $("#getRegYzm");
        var countdown1 = setInterval(countDown,1000);
        $.post('get_code', {
            type: 1
        }, function(d) {
            if (d.success) {
            	lay_msg(d.message);
            	
            } else {
            	lay_msg(d.message);
            }
        },'json')
        function countDown(){
            t-=1;     
            if(t>0){
                getRegYzm.attr("disabled","disabled");
                getRegYzm.addClass("dis");
                getRegYzm.val(t+"s后重新获取");
            }else{
                clearInterval(countdown1);
                getRegYzm.removeClass("dis");
                getRegYzm.val("重新获取");
                getRegYzm.removeAttr("disabled");
            }
        }
    }
    function setpwd() {
        var vcode = $("#zcvcode");
        if(vcode.val() == "") {
            var e = function() {
                vcode.focus();
            };
            lay_msg('请输入手机验证码！', e);
            return false;
        }

        var o_pd = $("#passwd");
        if(o_pd.val() == "") {
            var e = function() {
                o_pd.focus();
            };
            lay_msg('请设置密码！', e);
            return false;
        }
        if(o_pd.val().length < 6) {
            var e = function() {
                o_pd.focus();
            };
            lay_msg('密码至少需要6个字符！', e);
            return false;
        }
        var n_pd = $("#passwdse");
        if(n_pd.val() != o_pd.val()) {
            var e = function() {
                n_pd.focus();
            };
            lay_msg('两次密码输入不一样！', e);
            return false;
        }
        var name=$("#zcname");
        $.post('fotGetPassword', {
            name: name.val(),
            code: vcode.val(),
            password: o_pd.val()
        }, function(e) {
            if (e.success) {
            	lay_msg(e.message);
    			$(".step2").removeClass("on");
    			$(".step3").addClass("on");
	        	setTimeout(function(){
	        		window.location.href="/index.php/Login/index";
	        	},2000);
            } else {
            	lay_msg(e.message);
            }
        },'json')
    }
</script>
</body>
</html>